package org.redswallow.log;

import java.util.HashMap;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;


public class LogFactory {
	
	public static Map<String, Logger> loggers = new HashMap<String, Logger>();
    public static LogFactory instance;
    
    protected LogFactory ( ) {
    }
	
    protected static synchronized LogFactory getInstance ( ) {
        if ( instance == null ) {
            instance = new LogFactory();
        }
        return instance;
    }
    
    public static synchronized Logger getLog ( Class<?> category ) {
        return getLog ( category.getName() );
    }
    
    public static synchronized Logger getLog ( String category ) {
    	Logger log = loggers.get(category);
    	if (log==null) {
    		log = LoggerFactory.getLogger(category);
    		loggers.put(category, log);
    	}
    	return log;
    }
    
}
